package com.aspose.cells;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;

public class PivotTableCollection extends CollectionBase {
   Worksheet b;

   PivotTableCollection(Worksheet worksheet) {
      this.b = worksheet;
   }

   void a(PivotTableCollection var1) throws Exception {
      for(int var2 = 0; var2 < var1.getCount(); ++var2) {
         PivotTable var3 = new PivotTable(this);

         try {
            var3.a(var1.get(var2));
         } catch (Exception var5) {
            if ("Unkown Area".equals(var5.getMessage())) {
               continue;
            }
         }

         com.aspose.cells.b.a.a.ze.a(this.a, (Object)var3);
      }

   }

   void a(CellArea var1, int var2, int var3) {
      for(int var4 = 0; var4 < this.getCount(); ++var4) {
         if (this.get(var4).a(var1, var2, var3)) {
            this.removeAt(var4--);
         }
      }

   }

   void a(int var1, int var2) {
      for(int var3 = 0; var3 < this.getCount(); ++var3) {
         PivotTable var4 = this.get(var3);
         if (var4.b(var1, var2)) {
            this.removeAt(var3);
            if (!this.a(var4.d)) {
               this.b(var4.d);
            }
         }
      }

   }

   boolean a(zauk var1) {
      for(int var2 = 0; var2 < this.getCount(); ++var2) {
         PivotTable var3 = this.get(var2);
         if (var3.d == var1) {
            return true;
         }
      }

      return false;
   }

   Object[] a(PivotTable var1, Object[] var2) {
      com.aspose.cells.b.a.a.zd var3 = new com.aspose.cells.b.a.a.zd();
      com.aspose.cells.b.a.a.zd var4 = new com.aspose.cells.b.a.a.zd();
      com.aspose.cells.b.a.a.zd var5 = new com.aspose.cells.b.a.a.zd();
      String var6 = null;
      Object var7 = null;
      Object var8 = null;
      PivotField var9 = null;

      for(int var10 = 0; var10 < var2.length; var10 += 2) {
         var6 = com.aspose.cells.b.a.zr.a(var2[var10]);
         Object var10000 = var2[var10 + 1];
         var8 = var1.getBaseFields().a(var6);
         if (var8 != null) {
            var9 = (PivotField)var8;
            if (var9.m == 1) {
               var3.a(var9.getPosition(), new int[]{var10, var10 + 1});
            } else if (var9.m == 2) {
               var4.a(var9.getPosition(), new int[]{var10, var10 + 1});
            } else {
               var5.a(var9.getPosition(), new int[]{var10, var10 + 1});
            }
         }
      }

      Object[] var14 = new Object[var2.length];
      int var11 = 0;

      int[] var12;
      Iterator var13;
      for(var13 = var3.f().iterator(); var13.hasNext(); var14[var11++] = var2[var12[1]]) {
         var12 = (int[])((int[])var13.next());
         var14[var11++] = var2[var12[0]];
      }

      for(var13 = var4.f().iterator(); var13.hasNext(); var14[var11++] = var2[var12[1]]) {
         var12 = (int[])((int[])var13.next());
         var14[var11++] = var2[var12[0]];
      }

      for(var13 = var5.f().iterator(); var13.hasNext(); var14[var11++] = var2[var12[1]]) {
         var12 = (int[])((int[])var13.next());
         var14[var11++] = var2[var12[0]];
      }

      return var14;
   }

   zagu[] a(PivotTable var1, zagu[] var2, zaay var3) {
      com.aspose.cells.b.a.a.zd var4 = new com.aspose.cells.b.a.a.zd();
      com.aspose.cells.b.a.a.zd var5 = new com.aspose.cells.b.a.a.zd();
      com.aspose.cells.b.a.a.zd var6 = new com.aspose.cells.b.a.a.zd();
      String var7 = null;
      Object var8 = null;
      Object var9 = null;
      PivotField var10 = null;

      for(int var11 = 2; var11 < var2.length; var11 += 2) {
         var7 = var2[var11].i(var3).k();
         zagu var10000 = var2[var11 + 1];
         var9 = var1.getBaseFields().a(var7);
         if (var9 != null) {
            var10 = (PivotField)var9;
            if (var10.m == 1) {
               var4.a(var10.getPosition(), new int[]{var11, var11 + 1});
            } else if (var10.m == 2) {
               var5.a(var10.getPosition(), new int[]{var11, var11 + 1});
            } else {
               var6.a(var10.getPosition(), new int[]{var11, var11 + 1});
            }
         }
      }

      zagu[] var15 = new zagu[var2.length - 2];
      int var12 = 0;

      int[] var13;
      Iterator var14;
      for(var14 = var4.f().iterator(); var14.hasNext(); var15[var12++] = var2[var13[1]]) {
         var13 = (int[])((int[])var14.next());
         var15[var12++] = var2[var13[0]];
      }

      for(var14 = var5.f().iterator(); var14.hasNext(); var15[var12++] = var2[var13[1]]) {
         var13 = (int[])((int[])var14.next());
         var15[var12++] = var2[var13[0]];
      }

      for(var14 = var6.f().iterator(); var14.hasNext(); var15[var12++] = var2[var13[1]]) {
         var13 = (int[])((int[])var14.next());
         var15[var12++] = var2[var13[0]];
      }

      return var15;
   }

   Object a(int var1, int var2, String var3, Object[] var4) {
      new ArrayList();
      new ArrayList();
      HashMap var7 = new HashMap();
      HashMap var8 = new HashMap();
      boolean var9 = false;
      Cell var10 = null;
      int var11 = -1;

      for(int var12 = 0; var12 < this.getCount(); ++var12) {
         PivotTable var13 = this.get(var12);
         if (var1 >= var13.i && var1 <= var13.j && var2 >= var13.k && var2 <= var13.l) {
            PivotFieldCollection var14 = var13.getDataFields();

            for(int var15 = 0; var15 < var14.getCount(); ++var15) {
               PivotField var16 = var14.get(var15);
               if ((var16.getDisplayName() != null || var16.getName() != null) && (var16.getDisplayName().toUpperCase().endsWith(var3.toUpperCase()) || var16.getName().toUpperCase().endsWith(var3.toUpperCase()))) {
                  int var17;
                  if (var13.getDataField() != null && var13.getDataField().m == 2) {
                     var9 = true;
                     var17 = var13.a(var16);
                     var7.put(var17 + var13.o, var17 + var13.o);
                  }

                  Iterator var18;
                  int var19;
                  if (var4.length > 0) {
                     var4 = this.a(var13, var4);

                     for(var17 = 0; var17 < var4.length; var17 += 2) {
                        String var36 = com.aspose.cells.b.a.zr.a(var4[var17]);
                        Object var38 = var4[var17 + 1];
                        Object var20 = var13.getBaseFields().a(var36);
                        if (var20 == null) {
                           return zst.g;
                        }

                        PivotField var21 = (PivotField)var20;
                        ArrayList var5;
                        int var22;
                        int var23;
                        if (var21.m == 2) {
                           var5 = var13.a(var38, true);
                           if (var5.size() == 0) {
                              return zst.g;
                           }

                           var22 = var13.a(var21);

                           for(var23 = 0; var23 < var5.size(); ++var23) {
                              int[] var24 = (int[])((int[])var5.get(var23));
                              if (var24[0] == var22) {
                                 if (var7.containsKey(var24[1])) {
                                    if (var9) {
                                       break;
                                    }
                                 } else {
                                    if (var7.size() != 0) {
                                       return zst.g;
                                    }

                                    var7.put(var24[1], var24[1]);
                                 }
                              }
                           }
                        } else {
                           if (var21.m != 1) {
                              return zst.g;
                           }

                           ++var11;
                           var5 = var13.a(var38, false);
                           if (var5.size() == 0) {
                              return zst.g;
                           }

                           var22 = var13.a(var21);
                           var23 = -1;
                           int var41 = var22;

                           for(int var25 = var22 - 1; var25 >= 0; --var25) {
                              if (var13.getRowFields().get(var25).getShowInOutlineForm() && var13.getRowFields().get(var25).getShowCompact()) {
                                 --var41;
                              }
                           }

                           var41 += var13.k;
                           ArrayList var42 = new ArrayList();
                           int var26;
                           if (var22 > 0) {
                              if (var13.getRowFields().get(var22 - 1).getShowInOutlineForm() && var13.getRowFields().get(var22 - 1).getShowCompact()) {
                                 var42 = var13.a(var22);
                              } else {
                                 var23 = var22;

                                 for(var26 = var22 - 1; var26 >= 0; --var26) {
                                    if (var13.getRowFields().get(var26).getShowInOutlineForm() && var13.getRowFields().get(var26).getShowCompact()) {
                                       --var23;
                                    }
                                 }
                              }
                           } else if (var13.getRowFields().get(0).getShowInOutlineForm() && var13.getRowFields().get(0).getShowCompact()) {
                              var42 = var13.a(var22);
                           } else {
                              var23 = 0;
                           }

                           ArrayList var6;
                           if (var23 >= 0) {
                              var23 += var13.k;
                              var6 = this.a(var5, var23, var22);
                           } else {
                              var6 = this.a(var5, var42, var22, var41);
                           }

                           if (var8.size() == 0 && var11 == 0) {
                              for(var26 = 0; var26 < var6.size(); ++var26) {
                                 if (!var8.containsKey(((int[])((int[])var6.get(var26)))[0])) {
                                    var8.put(((int[])((int[])var6.get(var26)))[0], ((int[])((int[])var6.get(var26)))[1]);
                                 }
                              }
                           } else {
                              HashMap var43 = com.aspose.cells.b.a.a.zf.b(var8);

                              for(int var27 = 0; var27 < var6.size(); ++var27) {
                                 int var28 = ((int[])((int[])var6.get(var27)))[0];
                                 int var29 = ((int[])((int[])var6.get(var27)))[1];
                                 com.aspose.cells.b.a.a.zc var30 = com.aspose.cells.b.a.a.zf.a(var43);

                                 while(var30.c()) {
                                    int var31 = (Integer)var30.a();
                                    int var32 = (Integer)var30.b();
                                    int var33 = Math.min(var32, var29);
                                    boolean var34 = false;

                                    for(int var35 = 0; var35 <= var33; ++var35) {
                                       if (((int[])((int[])var13.g.get(var28 - var13.n)))[4 + var35] != ((int[])((int[])var13.g.get(var31 - var13.n)))[4 + var35]) {
                                          var34 = true;
                                          break;
                                       }
                                    }

                                    if (!var34 && var32 < var29) {
                                       var8.remove(var31);
                                       var8.put(var28, var29);
                                    }
                                 }
                              }
                           }

                           if (var8.size() == 1) {
                              com.aspose.cells.b.a.a.zc var44 = com.aspose.cells.b.a.a.zf.a(var8);
                              if (var44.c() && var23 != -1 && (Integer)var44.b() != var23) {
                                 return zst.g;
                              }
                           }
                        }
                     }

                     int var37;
                     if (var7.size() == 0) {
                        if (var8.size() != 0 && var8.size() <= 1) {
                           var17 = -1;

                           for(var18 = var8.keySet().iterator(); var18.hasNext(); var17 = var19) {
                              var19 = (Integer)var18.next();
                           }

                           var37 = (Integer)var8.get(var17);
                           if ((!var13.getRowFields().get(var37).getShowSubtotalAtTop() || !var13.getRowFields().get(var37).getShowInOutlineForm()) && var37 != var13.getRowFields().getCount() - 1) {
                              var17 = var13.a(var17, var37);
                           }

                           var10 = this.b.getCells().get(var17, var13.l);
                           return var10.F();
                        } else {
                           return zst.g;
                        }
                     } else {
                        var17 = -1;

                        for(var18 = var7.keySet().iterator(); var18.hasNext(); var17 = var19) {
                           var19 = (Integer)var18.next();
                        }

                        if (var8.size() == 0) {
                           var37 = var13.b(var13.a(var16));
                           var10 = this.b.getCells().get(var37 + var13.n, var17);
                           return var10.F();
                        } else if (var8.size() > 1) {
                           return zst.g;
                        } else {
                           var37 = -1;
                           var19 = -1;

                           int var40;
                           for(Iterator var39 = var8.keySet().iterator(); var39.hasNext(); var19 = (Integer)var8.get(var40)) {
                              var40 = (Integer)var39.next();
                              var37 = var40;
                           }

                           if ((!var13.getRowFields().get(var19).getShowSubtotalAtTop() || !var13.getRowFields().get(var19).getShowInOutlineForm()) && var19 != var13.getRowFields().getCount() - 1) {
                              var37 = var13.a(var37, var19);
                           }

                           var10 = this.b.getCells().get(var37, var17);
                           return var10.F();
                        }
                     }
                  } else {
                     var17 = -1;

                     for(var18 = var7.keySet().iterator(); var18.hasNext(); var17 = var19) {
                        var19 = (Integer)var18.next();
                     }

                     if (var7.size() != 0) {
                        var10 = this.b.getCells().get(var13.j, var17);
                     } else {
                        var10 = this.b.getCells().get(var13.j, var13.l);
                     }

                     return var10.F();
                  }
               }
            }
         }
      }

      return zst.g;
   }

   zagu a(int var1, int var2, String var3, zagu[] var4, zaay var5) {
      new ArrayList();
      new ArrayList();
      HashMap var8 = new HashMap();
      HashMap var9 = new HashMap();
      zzq var10 = new zzq();
      boolean var11 = false;
      Object var12 = null;
      int var13 = -1;

      for(int var14 = 0; var14 < this.getCount(); ++var14) {
         PivotTable var15 = this.get(var14);
         if (var1 >= var15.i && var1 <= var15.j && var2 >= var15.k && var2 <= var15.l) {
            PivotFieldCollection var16 = var15.getDataFields();

            for(int var17 = 0; var17 < var16.getCount(); ++var17) {
               PivotField var18 = var16.get(var17);
               if ((var18.getDisplayName() != null || var18.getName() != null) && (var18.getDisplayName().toUpperCase().endsWith(var3.toUpperCase()) || var18.getName().toUpperCase().endsWith(var3.toUpperCase()))) {
                  int var19;
                  if (var15.getDataField() != null && var15.getDataField().m == 2) {
                     var11 = true;
                     var19 = var15.a(var18);
                     var8.put(var19 + var15.o, var19 + var15.o);
                  }

                  Iterator var20;
                  int var21;
                  if (var4.length > 2) {
                     var4 = this.a(var15, var4, var5);

                     int var23;
                     for(var19 = 0; var19 < var4.length; var19 += 2) {
                        String var37 = var4[var19].i(var5).k();
                        var10.d(var4[var19 + 1]);
                        Object var39 = var15.getBaseFields().a(var37);
                        if (var39 == null) {
                           return zzf.a;
                        }

                        PivotField var22 = (PivotField)var39;
                        ArrayList var6;
                        int var24;
                        if (var22.m == 2) {
                           var6 = var15.a(var10, true, var5);
                           if (var6.size() == 0) {
                              return zzf.a;
                           }

                           var23 = var15.a(var22);

                           for(var24 = 0; var24 < var6.size(); ++var24) {
                              int[] var25 = (int[])((int[])var6.get(var24));
                              if (var25[0] == var23) {
                                 if (var8.containsKey(var25[1])) {
                                    if (var11) {
                                       break;
                                    }
                                 } else {
                                    if (var8.size() != 0) {
                                       return zzf.a;
                                    }

                                    var8.put(var25[1], var25[1]);
                                 }
                              }
                           }
                        } else {
                           if (var22.m != 1) {
                              return zzf.a;
                           }

                           ++var13;
                           var6 = var15.a(var10, false, var5);
                           if (var6.size() == 0) {
                              return zzf.a;
                           }

                           var23 = var15.a(var22);
                           var24 = -1;
                           int var41 = var23;

                           for(int var26 = var23 - 1; var26 >= 0; --var26) {
                              if (var15.getRowFields().get(var26).getShowInOutlineForm() && var15.getRowFields().get(var26).getShowCompact()) {
                                 --var41;
                              }
                           }

                           var41 += var15.k;
                           ArrayList var42 = new ArrayList();
                           int var27;
                           if (var23 > 0) {
                              if (var15.getRowFields().get(var23 - 1).getShowInOutlineForm() && var15.getRowFields().get(var23 - 1).getShowCompact()) {
                                 var42 = var15.a(var23);
                              } else {
                                 var24 = var23;

                                 for(var27 = var23 - 1; var27 >= 0; --var27) {
                                    if (var15.getRowFields().get(var27).getShowInOutlineForm() && var15.getRowFields().get(var27).getShowCompact()) {
                                       --var24;
                                    }
                                 }
                              }
                           } else if (var15.getRowFields().get(0).getShowInOutlineForm() && var15.getRowFields().get(0).getShowCompact()) {
                              var42 = var15.a(var23);
                           } else {
                              var24 = 0;
                           }

                           ArrayList var7;
                           if (var24 >= 0) {
                              var24 += var15.k;
                              var7 = this.a(var6, var24, var23);
                           } else {
                              var7 = this.a(var6, var42, var23, var41);
                           }

                           if (var9.size() == 0 && var13 == 0) {
                              for(var27 = 0; var27 < var7.size(); ++var27) {
                                 if (!var9.containsKey(((int[])((int[])var7.get(var27)))[0])) {
                                    var9.put(((int[])((int[])var7.get(var27)))[0], ((int[])((int[])var7.get(var27)))[1]);
                                 }
                              }
                           } else {
                              HashMap var43 = com.aspose.cells.b.a.a.zf.b(var9);

                              for(int var28 = 0; var28 < var7.size(); ++var28) {
                                 int var29 = ((int[])((int[])var7.get(var28)))[0];
                                 int var30 = ((int[])((int[])var7.get(var28)))[1];
                                 com.aspose.cells.b.a.a.zc var31 = com.aspose.cells.b.a.a.zf.a(var43);

                                 while(var31.c()) {
                                    int var32 = (Integer)var31.a();
                                    int var33 = (Integer)var31.b();
                                    int var34 = Math.min(var33, var30);
                                    boolean var35 = false;

                                    for(int var36 = 0; var36 <= var34; ++var36) {
                                       if (((int[])((int[])var15.g.get(var29 - var15.n)))[4 + var36] != ((int[])((int[])var15.g.get(var32 - var15.n)))[4 + var36]) {
                                          var35 = true;
                                          break;
                                       }
                                    }

                                    if (!var35 && var33 < var30) {
                                       var9.remove(var32);
                                       var9.put(var29, var30);
                                    }
                                 }
                              }
                           }

                           if (var9.size() == 1) {
                              com.aspose.cells.b.a.a.zc var44 = com.aspose.cells.b.a.a.zf.a(var9);
                              if (var44.c() && var24 != -1 && (Integer)var44.b() != var24) {
                                 return zzf.a;
                              }
                           }
                        }
                     }

                     int var38;
                     if (var8.size() == 0) {
                        if (var9.size() != 0 && var9.size() <= 1) {
                           var19 = -1;

                           for(var20 = var9.keySet().iterator(); var20.hasNext(); var19 = var21) {
                              var21 = (Integer)var20.next();
                           }

                           var38 = (Integer)var9.get(var19);
                           if ((!var15.getRowFields().get(var38).getShowSubtotalAtTop() || !var15.getRowFields().get(var38).getShowInOutlineForm()) && var38 != var15.getRowFields().getCount() - 1) {
                              var19 = var15.a(var19, var38);
                           }

                           return zaaq.a(this.b.getCells(), var19, var15.l, true, var5);
                        } else {
                           return zzf.a;
                        }
                     } else {
                        var19 = -1;

                        for(var20 = var8.keySet().iterator(); var20.hasNext(); var19 = var21) {
                           var21 = (Integer)var20.next();
                        }

                        if (var9.size() == 0) {
                           var38 = var15.b(var15.a(var18));
                           return zaaq.a(this.b.getCells(), var38 + var15.n, var19, true, var5);
                        } else if (var9.size() > 1) {
                           return zzf.a;
                        } else {
                           var38 = -1;
                           var21 = -1;

                           for(Iterator var40 = var9.keySet().iterator(); var40.hasNext(); var21 = (Integer)var9.get(var23)) {
                              var23 = (Integer)var40.next();
                              var38 = var23;
                           }

                           if ((!var15.getRowFields().get(var21).getShowSubtotalAtTop() || !var15.getRowFields().get(var21).getShowInOutlineForm()) && var21 != var15.getRowFields().getCount() - 1) {
                              var38 = var15.a(var38, var21);
                           }

                           return zaaq.a(this.b.getCells(), var38, var19, true, var5);
                        }
                     }
                  } else {
                     var19 = -1;
                     if (var8.size() == 0) {
                        var19 = var15.l;
                     } else {
                        for(var20 = var8.keySet().iterator(); var20.hasNext(); var19 = var21) {
                           var21 = (Integer)var20.next();
                        }
                     }

                     return (zagu)(var19 < 0 ? zzk.a : zaaq.a(this.b.getCells(), var15.j, var19, true, var5));
                  }
               }
            }
         }
      }

      return zzf.a;
   }

   ArrayList a(ArrayList var1, ArrayList var2, int var3, int var4) {
      ArrayList var5 = new ArrayList();

      for(int var6 = 0; var6 < var1.size(); ++var6) {
         for(int var7 = 0; var7 < var2.size(); ++var7) {
            if (((int[])((int[])var1.get(var6)))[0] == (Integer)var2.get(var7) && ((int[])((int[])var1.get(var6)))[1] == var4) {
               com.aspose.cells.b.a.a.ze.a(var5, (Object)(new int[]{(Integer)var2.get(var7), var3}));
            }
         }
      }

      return var5;
   }

   ArrayList a(ArrayList var1, int var2, int var3) {
      ArrayList var4 = new ArrayList();

      for(int var5 = 0; var5 < var1.size(); ++var5) {
         if (((int[])((int[])var1.get(var5)))[1] == var2) {
            com.aspose.cells.b.a.a.ze.a(var4, (Object)(new int[]{((int[])((int[])var1.get(var5)))[0], var3}));
         }
      }

      return var4;
   }

   void b(zauk var1) {
      if (this.b.getWorkbook().getWorksheets().U() != null && this.b.getWorkbook().getWorksheets().U().getCount() != 0) {
         int var2 = this.b.getWorkbook().getWorksheets().U().getCount();

         for(int var3 = 0; var3 < var2; ++var3) {
            zauk var4 = this.b.getWorkbook().getWorksheets().U().a(var3);
            if (var1 == var4) {
               this.b.getWorkbook().getWorksheets().U().removeAt(var3);
            }
         }
      }

   }

   ArrayList a() {
      ArrayList var1 = new ArrayList();

      for(int var2 = 0; var2 < this.getCount(); ++var2) {
         PivotTable var3 = this.get(var2);
         CellArea var4 = new CellArea();
         var4.StartRow = var3.i;
         var4.EndRow = var3.j;
         var4.StartColumn = var3.k;
         var4.EndColumn = var3.l;
         com.aspose.cells.b.a.a.ze.a(var1, (Object)var4);
      }

      return var1;
   }

   public int add(String sourceData, String destCellName, String tableName) {
      byte var4 = 0;
      byte var5 = 0;
      int[] var6 = new int[]{var4};
      int[] var7 = new int[]{var5};
      CellsHelper.a(destCellName, var6, var7);
      int var8 = var6[0];
      int var9 = var7[0];
      return this.add(sourceData, var8, var9, tableName);
   }

   public int add(String sourceData, String destCellName, String tableName, boolean useSameSource) {
      byte var5 = 0;
      byte var6 = 0;
      int[] var7 = new int[]{var5};
      int[] var8 = new int[]{var6};
      CellsHelper.a(destCellName, var7, var8);
      int var9 = var7[0];
      int var10 = var8[0];
      return this.add(sourceData, var9, var10, tableName, useSameSource);
   }

   public int add(String sourceData, int row, int column, String tableName) {
      zaul var5 = this.b.c().U();
      int var6 = var5.a(sourceData, this.b, true);
      return this.a(var5.a(var6), row, column, tableName);
   }

   public int add(String sourceData, int row, int column, String tableName, boolean useSameSource) {
      zaul var6 = this.b.c().U();
      int var7 = var6.a(sourceData, this.b, useSameSource);
      return this.a(var6.a(var7), row, column, tableName);
   }

   public int add(PivotTable pivotTable, String destCellName, String tableName) {
      byte var4 = 0;
      byte var5 = 0;
      int[] var6 = new int[]{var4};
      int[] var7 = new int[]{var5};
      CellsHelper.a(destCellName, var6, var7);
      int var8 = var6[0];
      int var9 = var7[0];
      return this.add(pivotTable, var8, var9, tableName);
   }

   public int add(PivotTable pivotTable, int row, int column, String tableName) {
      return this.a(pivotTable.d, row, column, tableName);
   }

   public int add(String[] sourceData, boolean isAutoPage, PivotPageFields pageFields, String destCellName, String tableName) {
      byte var6 = 0;
      byte var7 = 0;
      int[] var8 = new int[]{var6};
      int[] var9 = new int[]{var7};
      CellsHelper.a(destCellName, var8, var9);
      int var10 = var8[0];
      int var11 = var9[0];
      return this.add(sourceData, isAutoPage, pageFields, var10, var11, tableName);
   }

   public int add(String[] sourceData, boolean isAutoPage, PivotPageFields pageFields, int row, int column, String tableName) {
      zaul var7 = this.b.c().U();
      int var8 = var7.a((byte)4, sourceData, isAutoPage, pageFields);
      zauk var9 = var7.a(var8);
      return this.a(var9, row, column, tableName);
   }

   int a(zauk var1, int var2, int var3, String var4) {
      PivotTable var5 = new PivotTable(this, var1, var2, (short)var3, var4);
      this.b.getWorkbook().getSettings().a();
      com.aspose.cells.b.a.a.ze.a(this.a, (Object)var5);
      return this.getCount() - 1;
   }

   public PivotTable get(int index) {
      return (PivotTable)this.a.get(index);
   }

   public PivotTable get(String name) {
      for(int var2 = 0; var2 < this.getCount(); ++var2) {
         PivotTable var3 = (PivotTable)this.a.get(var2);
         if (var3.getName() != null && var3.getName().toUpperCase().equals(name.toUpperCase())) {
            return var3;
         }
      }

      return null;
   }

   public PivotTable get(int row, int column) {
      for(int var3 = 0; var3 < this.getCount(); ++var3) {
         PivotTable var4 = (PivotTable)this.a.get(var3);
         if (row >= var4.i && row <= var4.j && column >= var4.k && column <= var4.l) {
            return var4;
         }
      }

      return null;
   }

   public void clear() {
      for(int var1 = 0; var1 < this.getCount(); ++var1) {
         this.removeAt(var1);
      }

   }

   void a(PivotTable var1) {
      this.b.getWorkbook().getSettings().a();
      com.aspose.cells.b.a.a.ze.a(this.a, (Object)var1);
   }

   public void remove(PivotTable pivotTable) {
      --pivotTable.d.o;
      if (pivotTable.d.o <= 0) {
         this.b.c().U().c(pivotTable.d);
      }

      pivotTable.clearData();
      this.a.remove(pivotTable);
   }

   public void removeAt(int index) {
      this.remove(this.get(index));
   }

   boolean b(int var1, int var2) {
      int var3 = this.getCount();
      PivotTable var4 = null;
      Cell var5 = null;

      for(int var6 = 0; var6 < var3; ++var6) {
         var4 = this.get(var6);
         if (var4.D && var1 >= var4.i && var1 <= var4.n && var2 >= var4.k && var2 <= var4.o + var4.getColumnFields().getCount()) {
            var5 = this.b.getCells().a(var1, var2, false);
            if ("Row Labels".equals(var5.getStringValue()) || "Column Labels".equals(var5.getStringValue())) {
               return true;
            }

            if (var2 < var4.o) {
               if (this.a(var5.getStringValue(), var4)) {
                  return true;
               }
            } else if (this.b(var5.getStringValue(), var4)) {
               return true;
            }
         }
      }

      return false;
   }

   boolean a(String var1, PivotTable var2) {
      PivotFieldCollection var3 = var2.getRowFields();
      int var4 = var3.getCount();
      PivotField var5 = null;

      for(int var6 = 0; var6 < var4; ++var6) {
         var5 = var3.get(var6);
         if (var5.getName().equals(var1) || var5.getDisplayName() != null && var5.getDisplayName().equals(var1)) {
            return true;
         }
      }

      return false;
   }

   boolean b(String var1, PivotTable var2) {
      PivotFieldCollection var3 = var2.getColumnFields();
      int var4 = var3.getCount();
      PivotField var5 = null;

      for(int var6 = 0; var6 < var4; ++var6) {
         var5 = var3.get(var6);
         if (var5.getName().equals(var1) || var5.getDisplayName() != null && var5.getDisplayName().equals(var1)) {
            return true;
         }
      }

      return false;
   }
}
